package com.molichuxing.services.infrastructure.convertor;

import java.util.ArrayList;
import java.util.List;

import org.springframework.beans.BeanUtils;

import com.molichuxing.services.infrastructure.bean.EntrepotStorageBean;
import com.molichuxing.services.infrastructure.bean.StockBean;
import com.molichuxing.services.infrastructure.bean.StockCarBean;
import com.molichuxing.services.infrastructure.bean.StockRecordBean;
import com.molichuxing.services.infrastructure.bean.StockStoreBean;
import com.molichuxing.services.infrastructure.dto.response.EntrepotStorageDto;
import com.molichuxing.services.infrastructure.dto.response.StockCarDto;
import com.molichuxing.services.infrastructure.dto.response.StockDto;
import com.molichuxing.services.infrastructure.dto.response.StockRecordDto;
import com.molichuxing.services.infrastructure.dto.response.StockStoreDto;

/**
 * 
 * @author liyg 基础服务数据转换类 2019-08-20
 *
 */
public class Convert {

	public static List<EntrepotStorageDto> toEntrepotStorageDto(List<EntrepotStorageBean> beanList) {
		List<EntrepotStorageDto> dtoList = null;
		if (beanList != null && beanList.size() > 0) {
			dtoList = new ArrayList<>();
			for (EntrepotStorageBean bean : beanList) {
				dtoList.add(toEntrepotStorageDto(bean));
			}
		}

		return dtoList;
	}

	public static EntrepotStorageDto toEntrepotStorageDto(EntrepotStorageBean bean) {
		EntrepotStorageDto dto = null;
		if (bean != null) {
			dto = new EntrepotStorageDto();
			BeanUtils.copyProperties(bean, dto);
		}
		return dto;
	}

	public static List<StockDto> toStockDto(List<StockBean> beanList) {
		List<StockDto> dtoList = null;
		if (beanList != null && beanList.size() > 0) {
			dtoList = new ArrayList<>();
			for (StockBean bean : beanList) {
				dtoList.add(toStockDto(bean));
			}
		}

		return dtoList;
	}

	public static StockDto toStockDto(StockBean bean) {
		StockDto dto = null;
		if (bean != null) {
			dto = new StockDto();
			BeanUtils.copyProperties(bean, dto);
		}
		return dto;
	}
	
	public static List<StockRecordDto> toStockRecordDto(List<StockRecordBean> beanList) {
		List<StockRecordDto> dtoList = null;
		if (beanList != null && beanList.size() > 0) {
			dtoList = new ArrayList<>();
			for (StockRecordBean bean : beanList) {
				dtoList.add(toStockRecordDto(bean));
			}
		}

		return dtoList;
	}

	public static StockRecordDto toStockRecordDto(StockRecordBean bean) {
		StockRecordDto dto = null;
		if (bean != null) {
			dto = new StockRecordDto();
			BeanUtils.copyProperties(bean, dto);
		}
		return dto;
	}
	
	public static List<StockStoreDto> toStockStoreDto(List<StockStoreBean> beanList) {
		List<StockStoreDto> dtoList = null;
		if (beanList != null && beanList.size() > 0) {
			dtoList = new ArrayList<>();
			for (StockStoreBean bean : beanList) {
				dtoList.add(toStockStoreDto(bean));
			}
		}

		return dtoList;
	}

	public static StockStoreDto toStockStoreDto(StockStoreBean bean) {
		StockStoreDto dto = null;
		if (bean != null) {
			dto = new StockStoreDto();
			BeanUtils.copyProperties(bean, dto);
		}
		return dto;
	}
	
	public static List<StockCarDto> toStockCarDto(List<StockCarBean> beanList) {
		List<StockCarDto> dtoList = null;
		if (beanList != null && beanList.size() > 0) {
			dtoList = new ArrayList<>();
			for (StockCarBean bean : beanList) {
				dtoList.add(toStockCarDto(bean));
			}
		}

		return dtoList;
	}
	
	public static StockCarDto toStockCarDto(StockCarBean bean) {
		StockCarDto dto = null;
		if (bean != null) {
			dto = new StockCarDto();
			BeanUtils.copyProperties(bean, dto);
		}
		return dto;
	}
}
